

package kr.ac.ssu.yoobh17.mPlayer.list_music;


import kr.ac.ssu.yoobh17.mPlayer.R;
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.TextView;


public class MusicListCursorAdapter extends CursorAdapter {

	public MusicListCursorAdapter( Context context, Cursor c ) {

		this( context, c, true );
		// TODO Auto-generated constructor stub

	}

	public MusicListCursorAdapter( Context context, Cursor c, boolean autoRequery ) {

		super( context, c, autoRequery );
		// TODO Auto-generated constructor stub

	}

	@Override
	public View newView( Context context, Cursor cursor, ViewGroup parent ) {

		// TODO Auto-generated method stub

		LayoutInflater 	layoutInflater 	= LayoutInflater.from( context );
		View 			mapingLayout 	= layoutInflater.inflate( R.layout.listview_item_music, null );

		return mapingLayout;
	}

	@Override
	public void bindView( View view, Context context, Cursor cursor ) {

		// TODO Auto-generated method stub

		TextView 	textView_musicTitle 	= (TextView) view.findViewById( R.id.textView_music_title_item );
		TextView 	textView_musicArtist 	= (TextView) view.findViewById( R.id.textView_music_artist_item );

		String 		musicTitle 				= cursor.getString( 1 );
		String 		musicArtist 			= String.format( "%s - %s", cursor.getString( 2 ), cursor.getString( 3 ) );

		textView_musicTitle	.setText( musicTitle );
		textView_musicArtist.setText( musicArtist );

	}

}
